<?php
    class crop{
        private $cropID;
        
        public function __construct() {
            $args = func_get_args();
        }
        
        function setCropID($cropID){
            $this->cropID=$cropID;
        }
        function getCropID($cropID){
            return $this->cropID;
        }
        function getCrop(){
            $mysqli=  connect();
            $query="
                select  *
                from    member_farm_crop
                where   cropID='".$this->cropID."'
                ";
            $result=  $mysqli->query($query);
            $row=  $result->fetch_array(MYSQLI_ASSOC);
            return $row;
        }
        function getCost($costID){
            $mysqli=  connect();
            $query="
                select  *
                from    crop_cost
                where   cropID='".$this->cropID."' and
                        costID='".$costID."'
                ";
            $result=  $mysqli->query($query);
            $row=  $result->fetch_array(MYSQLI_ASSOC);
            return $row["cost"];
        }
        function setCost($costID,$cost){
            $mysqli=  connect();
            if($this->checkCost($costID)){
                $query="
                    update  crop_cost
                    set     cost='".$cost."'
                    where   cropID='".$this->cropID."' and
                            costID='".$costID."'
                    ";
                $result=$mysqli->query($query);
            }
        }
        function checkCost($costID){
            $mysqli=  connect();
            $query="
                select  *
                from    crop_cost
                where   costID='".$costID."' and
                        cropID='".$this->cropID."'
                ";
            $result=$mysqli->query($query);
            if($result->num_rows>0){
                return TRUE;
            }else{
                return FALSE;
            }
        }
    }